//
// Created by Administrator on 2015/5/22.
//

#pragma once

#include <cstdint>
#include <sys/types.h>
#include "es.h"


namespace esvr {

    void es_init_sock_module() noexcept;

    void es_destroy_sock_module() noexcept;

    socket_t es_init_svr(const char* /*ip*/, uint16_t /*port*/) noexcept;

    socket_t es_init_cli() noexcept;

    int es_listen(socket_t /*fd*/) noexcept;

    int es_connect(socket_t /*fd*/, const char* /*ip*/, uint16_t /*port*/) noexcept;

    void es_close(socket_t /*fd*/) noexcept;

    socket_t es_accept(socket_t /*svr_fd*/) noexcept;

    int es_send(socket_t /*fd*/, const char* /*buffer*/, const size_t /*len*/) noexcept;

    int es_recv(socket_t /*fd*/, char* /*buffer*/, const size_t /*max_size*/) noexcept;

    void es_setopt(socket_t /*fd*/, int /*optname*/, const void* /*optval*/, socklen_t /*optlen*/) noexcept;

    void es_getopt(socket_t /*fd*/, int /*optname*/, void* /*optval*/, socklen_t* /*optlen*/) noexcept;

    void es_fcntl(socket_t /*fd*/, int /*flags*/, bool /*open*/=true) noexcept;
};
